Authorization
憑證)。POST
dify-test
Using 'Respond to Webhook' Node
(確保 AI 回覆後才回傳)http://localhost:5678/webhook-test/dify-test
)POST
https://api.dify.ai/v1/chat-messages
Authorization
= Bearer 你的Dify API金鑰
JSON
{
"inputs": {},
"query": "{{$json['body']['message']}}",
"response_mode": "blocking",
"user": "api-user"
}
JSON
={{$json["answer"]}}
First Incoming Item
(會把 Set 節點輸出的 JSON {"reply":"..."}
回傳給呼叫者)。啟用 Workflow 後,使用 PowerShell 執行 POST 請求,將帶有中文的 JSON ({"message": "今天天氣怎樣"}
) 傳給 Webhook。
powershell
$json = '{"message":"今天天氣怎樣"}'
Invoke-RestMethod -Uri "http://localhost:5678/webhook-test/dify-test" `
-Method POST `
-Headers @{ "Content-Type" = "application/json; charset=utf-8" } `
-Body ([System.Text.Encoding]::UTF8.GetBytes($json))
HTTP Resquest 運轉畫面:
n8n Output畫面: